package com.taxi.driver.module.main;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.taxi.driver.R;
import com.taxi.driver.common.AppController;
import com.taxi.driver.module.main.mine.MineFragment;

public class MainPagerAdapter extends FragmentPagerAdapter {

    private String[] titles; //标题

    public MainPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        titles = context.getResources().getStringArray(R.array.main_titles);
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return MineFragment.newInstance();
            case 1:
                return AppController.getHomeFragment();
            case 2:
                return AppController.getOrderListFragment();
            default:
                throw new Error("no this position");
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public int getCount() {
        return 3;
    }

}